{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "062f54be",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 登陆系统\n",
    "\n",
    "# 简单的数据结构有 ： 数值和字符串\n",
    "# 模拟数据库数据 复杂的数据结构：列表\n",
    "user_data = \"guosiwen\"\n",
    "password_data = \"123456\"\n",
    "\n",
    "# 登录次数为3\n",
    "count = 3\n",
    "while True:\n",
    "    count -= 1     # 每输入一次，次数减一\n",
    "\n",
    "# 用户输入数据\n",
    "    username = input(\"请输入您的账号：\")\n",
    "    password = input(\"请输入您的密码：\")\n",
    "\n",
    "    # 登录中\n",
    "    # 优化： 1. 输入不正确时继续输入。   2. 设置输入失败的次数。\n",
    "    #   先判断账号是否正确\n",
    "    if user_data == username:\n",
    "        # 再判断密码\n",
    "        if password_data == password:\n",
    "            # 占位符 %s\n",
    "            print(\"欢迎\", username, \"使用本网站\")\n",
    "            break\n",
    "        else:\n",
    "            if count == 0:\n",
    "                print(\"你都输入三次了！不许输了！五分钟后再来吧！\")\n",
    "                break\n",
    "            else:\n",
    "                print(\"您输入的账号或密码不正确，请重新输入。您还有\", count, \"次机会\")\n",
    "    else:\n",
    "        if count == 0:\n",
    "            print(\"你都输入三次了！不许输了！五分钟后再来吧！\")\n",
    "            break\n",
    "        else:\n",
    "            print(\"您输入的账号或密码不正确，请重新输入。您还有\", count, \"次机会\")\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
